package com.hong.serviceuser.receiver;

import com.hong.model.model.user.UserInfo;
import com.hong.model.vo.msm.MsmVo;
import com.hong.rabbitutil.constant.MqConst;
import com.hong.serviceuser.mapper.UserInfoMapper;
import com.hong.serviceuser.service.UserInfoService;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.TimeUnit;

@Component
public class UserReceiver {
    @Autowired
    private UserInfoMapper userInfoMapper;
    @Autowired
    private RedisTemplate redisTemplate;
    /**
     * 使用 mq进行监听
     */
    @RabbitListener(
            bindings = @QueueBinding(value = @Queue(value = MqConst.QUEUE_USER_ITEM, durable = "true"),
                    exchange = @Exchange(value = MqConst.EXCHANGE_DIRECT_USER),
                    key = {MqConst.ROUTING_USER_ITEM}
            ))
    public void receive(UserInfo userInfo){
        userInfoMapper.updateById(userInfo);
    }
}
